﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 新增排班表和补贴规则表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SysAttendanceShift",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    DisplayColor = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    Tag = table.Column<int>(type: "int", nullable: true),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
                    WorkStartDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkStartTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    WorkStartPunchStartDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkStartPunchStartTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    WorkStartPunchEndDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkStartPunchEndTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    WorkEndDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkEndTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    WorkEndPunchStartDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkEndPunchStartTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    WorkEndPunchEndDayOffset = table.Column<int>(type: "int", nullable: false),
                    WorkEndPunchEndTime = table.Column<TimeSpan>(type: "time", nullable: false),
                    AttendanceViolationRuleEnabled = table.Column<bool>(type: "bit", nullable: false),
                    LateMinutesThreshold = table.Column<int>(type: "int", nullable: false),
                    EarlyLeaveMinutesThreshold = table.Column<int>(type: "int", nullable: false),
                    AbsenceByLateMinutesThreshold = table.Column<int>(type: "int", nullable: false),
                    AbsenceByEarlyLeaveMinutesThreshold = table.Column<int>(type: "int", nullable: false),
                    AbsenceByTotalDeviationMinutesThreshold = table.Column<int>(type: "int", nullable: false),
                    StandardWorkMinutes = table.Column<int>(type: "int", nullable: false),
                    AttendanceDays = table.Column<decimal>(type: "decimal(4,2)", nullable: false),
                    SubsidyRuleEnabled = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysAttendanceShift", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "SysAttendanceSubsidyRule",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    RuleType = table.Column<int>(type: "int", nullable: false),
                    EffectiveStartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    EffectiveEndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
                    AttendanceTimeConditionEnabled = table.Column<bool>(type: "bit", nullable: false),
                    MinAttendanceHours = table.Column<decimal>(type: "decimal(8,2)", nullable: true),
                    CheckinTimeConditionEnabled = table.Column<bool>(type: "bit", nullable: false),
                    CheckinStartDayOffset = table.Column<int>(type: "int", nullable: false),
                    CheckinStartTime = table.Column<TimeSpan>(type: "time", nullable: true),
                    CheckinEndDayOffset = table.Column<int>(type: "int", nullable: false),
                    CheckinEndTime = table.Column<TimeSpan>(type: "time", nullable: true),
                    CheckoutTimeConditionEnabled = table.Column<bool>(type: "bit", nullable: false),
                    CheckoutStartDayOffset = table.Column<int>(type: "int", nullable: false),
                    CheckoutStartTime = table.Column<TimeSpan>(type: "time", nullable: true),
                    CheckoutEndDayOffset = table.Column<int>(type: "int", nullable: false),
                    CheckoutEndTime = table.Column<TimeSpan>(type: "time", nullable: true),
                    CalculationType = table.Column<int>(type: "int", nullable: false),
                    FixedAmount = table.Column<decimal>(type: "decimal(8,2)", nullable: true),
                    CalculationFormula = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
                    MaxAmount = table.Column<decimal>(type: "decimal(8,2)", nullable: true),
                    MinAmount = table.Column<decimal>(type: "decimal(8,2)", nullable: true),
                    SysAttendanceShiftID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysAttendanceSubsidyRule", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysAttendanceSubsidyRule_SysAttendanceShift_SysAttendanceShiftID",
                        column: x => x.SysAttendanceShiftID,
                        principalTable: "SysAttendanceShift",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysAttendanceSubsidyRule_SysAttendanceShiftID",
                table: "SysAttendanceSubsidyRule",
                column: "SysAttendanceShiftID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysAttendanceSubsidyRule");

            migrationBuilder.DropTable(
                name: "SysAttendanceShift");
        }
    }
}
